<div class="_topinfo">
    <div class="_storename">
        <!-- {{#if bus_info.info.logo_url}}
        <img style="width:45px;height:45px;margin:5px auto;display:block;" bind-src="{{bus_info.info.logo_url}}">{{/if}} -->{{bus_info.info.title}}
    </div>
    <div class="_search_box">
        <input type="text" class="_search_input" placeholder="请输入文字进行搜索" event-enter="{{'$Event.href'}}" bind-input="{{'$Cache.search_text'}}" />
        <a event-click="{{'$Event.href'}}">
            <button class="icon-search"></button>
        </a>
    </div>
</div>

{{#if bus_info.config.home_imgs.length}}
<picwall array-data-key="bus_info.config.home_imgs"></picwall>
{{/if}}

<!-- nav -->
<div class="nav">
    <a href="#default/goods_list?id=3">
        <button class="btn">全部商品</button>
    </a>
    <a href="#default/tags">
        <button class="btn">商品分类</button>
    </a>
    <a href="#default/storeinfo">
        <button class="btn">店铺介绍</button>
    </a>
    <a href="{{#if loginer}}mobile.personal.html{{#else}}#default/sign_in{{/if}}">
        <button class="btn">个人中心</button>
    </a>
</div>

<!-- goods -->
<div class="_main_goods">
    {{#each goods_list}}
    <mobilemaingoods href="#default/goods_details?id={{_id}}" src="{{preview_img_url}}?imageView/1/w/300/h/300" name="{{goods_name}}" intro="{{intro}}" price="{{price}}/{{unit}}"></mobilemaingoods>
    {{/each}}
</div>

<div class="bottom">
    <a href="#default/goods_list?id=3">点此查看更多商品</a>
</div>

<xmp type="tag" name="picwall">
    <div class="picwall">
        <div class="carosule">
            <div class="pic-show">
                {{#each ${array-data-key} }}
                <div style="z-index:{{$Parent.length-$Index}}" class="pic">
                    <a target="_blank" bind-href="{{href||'javascript:void 0'}}">
                        <img bind-src="{{img_url}}" bind-title="{{title}}" />
                    </a>
                </div>
                {{/each}}
            </div>
        </div>
    </div>
    <script type="text/vm">
function(vm) {
    var picwall = vm.queryElement({
        className: 'picwall'
    })[0];
    require(["jQuery"], function($) {
        var w = $(picwall).width();
        $(picwall).height(w * 0.35);
        var current_pic;
        setInterval(function _a() {
            var pics = $(".pic");
            current_pic || (current_pic = pics.first());
            var animating_pic = current_pic.fadeOut(800);
            current_pic = current_pic.next();
            if (current_pic.length == 0) {
                current_pic = null;
                pics.not(animating_pic).fadeIn(800);
                setTimeout(function(){
                    animating_pic.fadeIn();
                },810);
            }
            return _a;
        }(), 3500);
    });
}
    </script>
</xmp>

<xmp type="tag" name="mobilemaingoods">
    <div class="maingoods">
        <div class="goodsimg">
            <a href="${href}">
                <img bind-src="${src}" />
            </a>
        </div>
        <div class="goodsinfo">
            <div class="infoitem">
                <span class="name">${name}</span>
            </div>
            <div class="infoitem">
                <span class="intro">${intro}</span>
            </div>
            <div class="infoitem">
                <div class="item">
                    <span class="price">￥${price}</span>
                </div>
                <div class="item right">
                    {{#if num }}
                        {{#if $Top.loginer}}
                        <sbutton shadownum1="0 0 10px 1px" shadownum2="0 0 5px 0px" class="btn" text="立即购买" event-click="{{'$Top.$Event.goods_list.add_to_cart'}}"></sbutton>
                        {{#else}}
                        <a href="{{JumpHref}}" >
                            <sbutton shadownum1="0 0 10px 1px" shadownum2="0 0 5px 0px" class="btn" text="立即购买"></sbutton>
                        </a>
                        {{/if}}
                    {{#else}}
                    <a>
                        <sbutton shadownum1="0 0 10px 1px" shadownum2="0 0 5px 0px" class="btn disabled" text="暂时缺货" disabled="true"></sbutton>
                    </a>
                    {{/if}}
                </div>
            </div>
            <div class="infoitem">
                <div class="i icon-sina-weibo" event-click="{{'$Event.shareToWeibo'}}"></div>
                <div class="i icon-qq" event-click="{{'$Event.shareQzone'}}"></div>
                <!-- <div class="i icon-renren" event-click="{{'$Event.shareRenren'}}"></div> -->
            </div>
        </div>
    </div>
    <script type="text/vm">
        function(vm) {
            var goodsimg = vm.queryElement({
                className: "goodsimg"
            })[0];
            require(['common','jQuery'], function(jSouper,$) {
                var h = $(goodsimg).width() * 0.7;
                $(goodsimg).css('height', h);
                
                // 分享
                var title="我觉得#"+vm.get("goods_name")+"#不错，跟大家分享一下";
                var pic=vm.get("preview_img_url")+"?imageView/1/w/100/h/100"; 
                var rLink = location.host.toString()+"/mobile.main.html#default/goods_details?id="+vm.get('_id')+"&rcid="+App.get("loginer._id");
                var site=location.host;
                var summary=vm.get('intro');
                // 微博
                vm.set('$Event.shareToWeibo',function(){
                    window.open("http://service.weibo.com/share/share.php?pic=" + encodeURIComponent(pic) + "&title=" +encodeURIComponent(title.replace(/&nbsp;/g, " ").replace(/<br \/>/g, " ")) + "&url=" + encodeURIComponent(rLink),
                        "分享至新浪微博",
                        "toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no");
                });
                // QQ空间
                vm.set('$Event.shareQzone',function(){
                    window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title='+  
                       encodeURIComponent(title)+'&url='+encodeURIComponent(rLink)+'&summary='+  
                       encodeURIComponent(summary)+ '&site='+encodeURIComponent(site)  
                       ,'_blank','scrollbars=no,status=no,resizable=yes'); 
                });
                // vm.set('$Event.shareRenren',function(){
                //     window.open('http://share.renren.com/share/buttonshare/post/1004?title='+encodeURIComponent(title)+'&url='+  
                //          encodeURIComponent(rLink)+'&content='+encodeURIComponent(summary),'_blank',  
                //          'scrollbars=no,status=no,resizable=yes');   
                // })
                vm.set('JumpHref',"#default/sign_in?gid="+vm.get('_id'));
            });
        }
    </script>
</xmp>
